package cn.edu.scau.cmil.luochenghao.comprehensive;
import java.awt.event.*;
import java.awt.*;
import javax.imageio.ImageIO;
import javax.swing.*;
import java.io.*;

public class ConsoleClient extends JPanel{
    	
    public static void main(String[] args) throws IOException{
    	JFrame system= new JFrame("期末成绩管理系统");
    	//四个按钮四个功能
    	JButton buttonRecord=new JButton("录入信息");
    	buttonRecord.setFont(new Font("黑体",Font.PLAIN,20));
    	buttonRecord.setBounds(650, 233, 220, 80);
    	buttonRecord.setVisible(true);
    	JButton buttonLook=new JButton("查看已录入信息");
    	buttonLook.setFont(new Font("黑体",Font.PLAIN,20));
    	buttonLook.setBounds(650, 328, 220, 80);
    	buttonLook.setVisible(true);
    	JButton buttonScript=new JButton("打印成绩单");
    	buttonScript.setFont(new Font("黑体",Font.PLAIN,20));
    	buttonScript.setBounds(650, 423, 220, 80);
    	buttonScript.setVisible(true);
    	JButton buttonOutput=new JButton("输出信息到文本文件");
    	buttonOutput.setFont(new Font("黑体",Font.PLAIN,20));
    	buttonOutput.setBounds(650, 518, 220, 80);
    	buttonOutput.setVisible(true);
    	system.add(buttonRecord);
    	system.add(buttonLook);
    	system.add(buttonScript);
    	system.add(buttonOutput);
    	//背景
    	system.add(new JLabel(new ImageIcon(ImageIO.read(new File(System.getProperty("user.dir")+"/background.png")))));
        system.setBackground(Color.BLACK);
        system.setResizable(false);
        system.pack();
        system.setLocationRelativeTo(null);
    	system.setVisible(true);
    	system.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    	//保存信息的数组
    	String[][] student=new String[1000][10]; 
    	buttonRecord.addActionListener(new ActionListener()//录入信息
    	{
	    	public void actionPerformed(ActionEvent e)
	    	{
	    		Record.record(student);
	    	}
    	}
    	);
    	buttonLook.addActionListener(new ActionListener()//查看已录入信息
    	{
	    	public void actionPerformed(ActionEvent e)
	    	{
	    		Look.look(student);
	    	}
    	}
    	);
    	buttonScript.addActionListener(new ActionListener()//打印成绩单
    	{
	    	public void actionPerformed(ActionEvent e)
	    	{
	    		PrintTranscript.Print(student);
	    	}
    	}
    	);
    	buttonOutput.addActionListener(new ActionListener()//输出信息到文件
    	{
	    	public void actionPerformed(ActionEvent e)
	    	{
	    		if(Output.output(student))//输入成功
	    			JOptionPane.showMessageDialog(null, "信息成功已输出到Data.txt文档中", "输出成功", JOptionPane.INFORMATION_MESSAGE);
	    	}
    	}
    	);
        }
}

